package demo5;

import java.util.Objects;

class Student {
    String name;

    @Override
    public boolean equals(Object obj) {//重写equals方法
        Student student = (Student) obj;
        if(this.name.equals(student.name)) {
            return true;
        }else {
            return false;
        }
    }
}
public class Test {
    public static void main(String[] args) {
        Student student1 = new Student();
        student1.name = "John";
        Student student2 = new Student();
        student2.name = "John";
        System.out.println(student1 == student2);
        boolean flg = student1.equals(student2);
        System.out.println("flg = " + flg);
    }
}
